
install-terraform-provider-maas-dr-edition:
	mkdir -p build
	[ -f build/terraform-provider-maas_v1.1.1 ] || ( \
		cd build; \
		rm -rf terraform-provider-maas; \
		git clone --depth 1 git@code.deeproute.ai:deeproute-org/cloud/cloud/k8s-deployment/terraform-provider-maas.git; \
		cd terraform-provider-maas; \
		go build -o ../terraform-provider-maas_v1.1.1; \
	)

	mkdir -p ~/.terraform.d/plugins/terraform.local/local/maas/1.1.1/`go env GOOS`_`go env GOARCH`/
	cp build/terraform-provider-maas_v1.1.1 ~/.terraform.d/plugins/terraform.local/local/maas/1.1.1/`go env GOOS`_`go env GOARCH`/terraform-provider-maas_v1.1.1

install-terraform-provider-deeproute:
	mkdir -p build
	[ -f build/terraform-provider-deeproute_v0.0.1 ] || ( \
		cd build; \
		rm -rf terraform-provider-deeproute; \
		git clone --depth 1 git@code.deeproute.ai:deeproute-org/cloud/cloud/k8s-deployment/terraform-provider-deeproute.git; \
		cd terraform-provider-deeproute; \
		go build -o ../terraform-provider-deeproute_v0.0.1; \
	)

	mkdir -p ~/.terraform.d/plugins/`go env GOOS`_`go env GOARCH`/terraform-provider-deeproute_v0.0.1
	cp build/terraform-provider-deeproute_v0.0.1 ~/.terraform.d/plugins/`go env GOOS`_`go env GOARCH`/terraform-provider-deeproute_v0.0.1

reset-docker-build:
	rm -f build/terraform-linux-amd64-v1.4.5
	rm -f build/terraform-provider-alicloud_v1.199.0
	rm -f build/terraform-provider-deeproute_v0.0.1
	rm -f build/terraform-provider-maas_v1.1.1

docker-build:
	mkdir -p build

	[ -f build/terraform-provider-alicloud_v1.199.0 ] || ( \
		cd build; \
		rm -f terraform-provider-alicloud_1.199.0_linux_amd64.zip; \
		wget https://github.com/aliyun/terraform-provider-alicloud/releases/download/v1.199.0/terraform-provider-alicloud_1.199.0_linux_amd64.zip; \
		unzip terraform-provider-alicloud_1.199.0_linux_amd64.zip; \
	)

	[ -f build/terraform-provider-deeproute_v0.0.1 ] || ( \
		cd build; \
		rm -rf terraform-provider-deeproute; \
		git clone --depth 1 git@code.deeproute.ai:deeproute-org/cloud/cloud/k8s-deployment/terraform-provider-deeproute.git; \
		cd terraform-provider-deeproute; \
		export CGO_ENABLED=0; \
		GOOS=linux GOARCH=amd64 go build -o ../terraform-provider-deeproute_v0.0.1; \
	)

	[ -f build/terraform-provider-maas_v1.1.1 ] || ( \
		cd build; \
		rm -rf terraform-provider-maas; \
		git clone --depth 1 git@code.deeproute.ai:deeproute-org/cloud/cloud/k8s-deployment/terraform-provider-maas.git; \
		cd terraform-provider-maas; \
		export CGO_ENABLED=0; \
		GOOS=linux GOARCH=amd64 go build -o ../terraform-provider-maas_v1.1.1; \
	)

	docker build --no-cache --tag "reg.deeproute.ai/deeproute-production/ops-terraform:$(IMAGE_VERSION)" .
